package com.moco.launcher.fragment;

import android.view.View;
import android.view.animation.Animation;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;

public class WaitUI {
	static public void startWait(View mWait) {
		mWait.setVisibility(View.VISIBLE);
		startAlbumAnimation(mWait);
	}

	static public void stopWait(View mWait) {
		stopAlbumAnimation(mWait);
		mWait.setVisibility(View.GONE);
	}

	static private void startAlbumAnimation(View view) {
		RotateAnimation rotateAnimation = new RotateAnimation(0, 359,
				Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
				0.5f);
		rotateAnimation.setDuration(3000);
		rotateAnimation.setInterpolator(new LinearInterpolator());
		rotateAnimation.setRepeatCount(-1);
		rotateAnimation.setRepeatMode(Animation.RESTART);
		rotateAnimation.setFillAfter(true);
		rotateAnimation.setFillEnabled(true);

		if (view != null) {
			view.startAnimation(rotateAnimation);
		}
	}

	static private void stopAlbumAnimation(View view) {
		if (view != null) {
			view.clearAnimation();
		}
	}
}
